//
//  FormQueryController.m
//  PropertyMananger
//
//  Created by bh on 17/2/28.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "FormQueryController.h"
#import "FromQueryDetController.h"
#import "MCSearchBar.h"
#import "CheckSelectedView.h"
#import "SelectedMonthView.h"
#import "HouseInfoCell.h"
#import "MCUICollectionViewFlowLayout.h"
#import "LeftTableViewCell.h"
#import "CheckQueryHeaderView.h"
#import "HouseQueryModel.h"
#import "CheckReadModel.h"

@interface FormQueryController ()<SelectedMonthViewDelegate,UISearchBarDelegate,UITextFieldDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,strong) NSArray * titleArray;

@property (nonatomic,strong) CheckSelectedView * monthView;
@property (nonatomic,strong) CheckQueryHeaderView * headerView;

@property (nonatomic,strong) SelectedMonthView * selectedView;//弹出的view
@property (nonatomic,assign) NSInteger  selectedMonth;//选择月份下标

@property (nonatomic,strong) UICollectionView * collectionView;
@property (nonatomic,strong) NSMutableArray * floorArray;//楼栋数据源
@property (nonatomic,copy) NSString * BuildUnitId;//楼栋ID

@property (nonatomic,strong) NSMutableArray * checkArray;//抄表查询数据源
@property (nonatomic,strong) NSMutableArray * readedArray;//抄表查询数据源
@property (nonatomic,copy) NSString * selectedTime;//选择的的时间
@property (nonatomic,copy) NSString * yearStr;//系统年份
@property (nonatomic,copy) NSString * monthStr;//系统月份
@property (nonatomic,assign) BOOL isReading;



@end

@implementation FormQueryController
{
    NSInteger _selectIndex;
    BOOL _isScrollDown;
}

static NSString * cellID = @"infoCellID";
static  NSString * headerViewID = @"headerViewID";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _isScrollDown = YES;
    self.searchStr = @"";
    self.isReading = YES;
    
    _selectIndex = 0;
    
    self.BuildUnitId = self.buidUnitID;
    
    [self getYearAndMonthData];
    
    [self getCalendar];
    
    //  self.monthView.monthLabel.text = @"";
    
    [self initTitleViewName:@"抄表查询"];
    self.floorArray = [[NSMutableArray alloc]init];
    self.checkArray = [[NSMutableArray alloc]init];
    self.readedArray = [[NSMutableArray alloc]init];
    
    [self setupSearchBar];
    
    [self initTableViewWithView:self.view frame:CGRectMake(0, 50, 85, BHscreenH - 50 - 64) isGroup:NO];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    [self setupCollectionView];
    
    [self createPlaceHolder];
    
    //  [self.tableView reloadData];
    // [self.collectionView reloadData];
    //  [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];
    
    //   [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:_selectIndex] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
    
    //获取数据
    [self postFloorQueryData];
}

#pragma mark - collectionView
- (void)setupCollectionView
{
    MCUICollectionViewFlowLayout *layout = [[MCUICollectionViewFlowLayout alloc] init];
    // 设置item尺寸
    layout.itemSize = CGSizeMake(80, 100);
    // 设置item之间的间隔
    layout.minimumInteritemSpacing = 10;
    // 设置行之间间隔
    layout.minimumLineSpacing = 10;
    // 设置组的内边距
    layout.sectionInset = UIEdgeInsetsMake(10, 0, 30, 30);
    
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(85, 50, BHscreenW - 85, BHscreenH - 50 - 64) collectionViewLayout:layout];
    [self.view addSubview:self.collectionView];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    self.collectionView.pagingEnabled = YES;
    self.collectionView.bounces = NO;
    
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.showsVerticalScrollIndicator = NO;
    self.collectionView.backgroundColor = BHGrayColor;
    
    [self.collectionView registerClass:[HouseInfoCell class] forCellWithReuseIdentifier:cellID];
    [self.collectionView registerClass:[CheckQueryHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerViewID];
    
}
#pragma mark - UITableView DataSource Delegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.floorArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LeftTableViewCell *cell = [LeftTableViewCell cellWithTableView:tableView];
    
    HouseQueryModel * model = self.floorArray[indexPath.row];
    cell.name.text = model.Name;
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    _selectIndex = indexPath.row;
    HouseQueryModel * model = self.floorArray[indexPath.row];
    self.BuildUnitId = model.BuildUnitId;
    
    [self postCheckReadingQueryData];
    
    // [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:_selectIndex] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
    [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:_selectIndex inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
    
    [self.collectionView reloadData];
}

#pragma mark - UICollectionView DataSource Delegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    if (self.checkArray.count == 0) {
        
        return 1;
    }else{
    return 2;
    }
    
    
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    if (section == 0) {
        if (self.checkArray.count != 0) {
            
              return self.checkArray.count;
            
        }else{
        
         return self.readedArray.count;
        }
       
        
    }else if (section == 1){
        
     return self.readedArray.count;
       
    }
    
    return 0;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    HouseInfoCell * infoCell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
    
    if (indexPath.section == 0) {
        if (self.checkArray.count != 0) {
            
            CheckReadModel * model = self.checkArray[indexPath.row];
            
            infoCell.infoTitleLabel.text = model.RoomName;
            return infoCell;
        }else{
        
            CheckReadModel * model = self.readedArray[indexPath.row];
            
            infoCell.infoTitleLabel.text = model.RoomName;
            return infoCell;
        
        }
        
        
    }else if (indexPath.section == 1){
        
        CheckReadModel * model = self.readedArray[indexPath.row];
        
        infoCell.infoTitleLabel.text = model.RoomName;
        return infoCell;
    }
    
    return nil;
}
//组头
//这个方法是返回 Header的大小 size
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    return CGSizeMake(BHscreenW, 30);
}
//这个也是最重要的方法 获取Header的 方法。
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
        
        self.headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:headerViewID forIndexPath:indexPath];
        
        if (indexPath.section == 0) {
            if (self.checkArray.count != 0) {
                
                if(self.checkArray.count == 0){
                    self.headerView.iconImg.image = nil;
                    self.headerView.typeLabel.text = @"";
                    self.headerView.lineViewLeft.hidden = YES;
                    self.headerView.lineViewRight.hidden = YES;
                    
                }else{
                    
                    self.headerView.iconImg.image = IMG(@"ico_meter_reading");
                    self.headerView.typeLabel.text = @"未抄表";
                    self.headerView.typeLabel.textColor = BHColor(214, 21, 23);
                    
                    self.headerView.lineViewLeft.hidden = NO;
                    self.headerView.lineViewRight.hidden = NO;
                }

            }else{
            
                self.headerView.iconImg.image = IMG(@"ico_meter_reading_ash");
                self.headerView.typeLabel.text = @"已抄表";
                self.headerView.typeLabel.textColor = BHColor(102, 102, 102);
                
                self.headerView.lineViewLeft.hidden = NO;
                self.headerView.lineViewRight.hidden = NO;
            }
            
        }else if (indexPath.section == 1){
            
            if(self.readedArray.count == 0){
                
                self.headerView.iconImg.image = nil;
                self.headerView.typeLabel.text = @"";
                self.headerView.lineViewLeft.hidden = YES;
                self.headerView.lineViewRight.hidden = YES;
                
            }else{
                self.headerView.iconImg.image = IMG(@"ico_meter_reading_ash");
                self.headerView.typeLabel.text = @"已抄表";
                self.headerView.typeLabel.textColor = BHColor(102, 102, 102);
                
                self.headerView.lineViewLeft.hidden = NO;
                self.headerView.lineViewRight.hidden = NO;
            }
        }
        
        return self.headerView;
    }
    return nil;
}
// CollectionView分区标题即将展示
//- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
//{
//    // 当前CollectionView滚动的方向向上，CollectionView是用户拖拽而产生滚动的（主要是判断CollectionView是用户拖拽而滚动的，还是点击TableView而滚动的）
//    if (!_isScrollDown && collectionView.dragging)
//    {
//        [self selectRowAtIndexPath:indexPath.section];
//    }
//}
//
//// CollectionView分区标题展示结束
//- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupplementaryView:(nonnull UICollectionReusableView *)view forElementOfKind:(nonnull NSString *)elementKind atIndexPath:(nonnull NSIndexPath *)indexPath
//{
//    // 当前CollectionView滚动的方向向下，CollectionView是用户拖拽而产生滚动的（主要是判断CollectionView是用户拖拽而滚动的，还是点击TableView而滚动的）
//    if (_isScrollDown && collectionView.dragging)
//    {
//        [self selectRowAtIndexPath:indexPath.section + 1];
//    }
//}

// 当拖动CollectionView的时候，处理TableView
//- (void)selectRowAtIndexPath:(NSInteger)index
//{
//    [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];
//}
#pragma mark - 点击查看详情
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    FromQueryDetController * detailVC = [[FromQueryDetController alloc]init];
    if (indexPath.section == 0) {
        if (self.checkArray.count != 0) {
            
             detailVC.model = self.checkArray[indexPath.row];
        }else{
        
             detailVC.model = self.readedArray[indexPath.row];
        }
       
    }else if (indexPath.section == 1){
        
        detailVC.model = self.readedArray[indexPath.row];
    }
    
    [self.navigationController pushViewController:detailVC animated:YES];
    
}
#pragma mark - UIScrollView Delegate
// 标记一下CollectionView的滚动方向，是向上还是向下
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    static float lastOffsetY = 0;
    
    if (self.collectionView == scrollView)
    {
        _isScrollDown = lastOffsetY < scrollView.contentOffset.y;
        lastOffsetY = scrollView.contentOffset.y;
    }
}

#pragma mark - 搜索框
- (void)setupSearchBar
{
    UIView * bgView = [[UIView alloc]init];
    [self.view addSubview:bgView];
    bgView.backgroundColor = BHGrayColor;
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.view).with.offset(85);
        make.top.equalTo(self.view).offset(0);
        make.size.mas_equalTo(CGSizeMake(BHscreenW - 85, 50));
    }];
    
    self.searchBar = [[MCSearchBar alloc] initWithFrame:CGRectMake(90, 7.5, BHscreenW - 100, 35) placeholder:nil];
    self.searchBar.delegate = self;
    self.searchBar.placeholder = @"请输入房间号";
    self.searchBar.barTintColor = [UIColor whiteColor];
    self.searchBar.searchTextField.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.searchBar];
    [self.searchBar setBackgroundColor:BHColor(237, 237, 237)];
    self.searchBar.layer.cornerRadius = 18.0f;
    self.searchBar.layer.masksToBounds = YES;
    self.searchBar.layer.borderWidth = 0.5;
    self.searchBar.layer.borderColor = BHColor(237, 237, 237).CGColor;
    self.searchBar.backgroundColor = [UIColor whiteColor];
    self.searchText = @"";
    
    self.searchBar.searchBarStyle = UISearchBarStyleDefault;
    
#pragma mark - 选择月份查询
    self.monthView = [[CheckSelectedView alloc]initWithFrame:CGRectMake(0, 0, 85, 50)];
    [self.monthView.selectedMonthBtn addTarget:self action:@selector(selectedMonthBtn:) forControlEvents:UIControlEventTouchUpInside];
    self.monthView.monthLabel.text = self.monthStr;
    [self.view addSubview:self.monthView];
    
}
#pragma mark - 搜索代理方法
- (BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    
    if (range.location == 0) {
        
        [self.resultArr removeAllObjects];
        [self.collectionView reloadData];
    }
    return YES;
}
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
    
    return YES;
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    
    
    [self.checkArray removeAllObjects];
    [self.readedArray removeAllObjects];
    [self postCheckReadingQueryData];
    
    [self.collectionView reloadData];
    [self.view endEditing:YES];
    
}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
    DLog(@"点击取消");
    self.isSearch = NO;
    
    self.searchStr = @"";
    [self.tableView reloadData];
    
    [searchBar resignFirstResponder];
    
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
    
    [self.searchBar resignFirstResponder];
    
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.tableView endEditing:YES];
    [self.view resignFirstResponder];
    [self.view endEditing:YES];
    self.isSearch = NO;
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
    if (searchText.length == 0) {
        
        self.searchText = @"";
        self.isSearch = NO;
        self.placehoderImg.hidden = YES;
        self.titleLabel.hidden = YES;
        
        //    [self.resultArr removeAllObjects];
        [self.collectionView reloadData];
    }
    
    self.searchStr = searchText;
    [self.resultArr removeAllObjects];
    
    for (CheckReadModel * model in self.checkArray) {
        if ([model.RoomName rangeOfString:searchText].location != NSNotFound) {
            [self.resultArr addObject:model.RoomName];
        }
    }
    
    for (CheckReadModel * model in self.readedArray) {
        
        if ([model.RoomName rangeOfString:searchText].location != NSNotFound) {
            [self.resultArr addObject:model.RoomName];
        }
    }
    
    if (self.resultArr.count != 0) {
        self.isSearch = YES;
        [self.tableView reloadData];
    }
    
}
- (void)searchBarResultsListButtonClicked:(UISearchBar *)searchBar{
    
    DLog(@"点击清除按钮");
}

#pragma mark - 点击选择月份
- (void)selectedMonthBtn:(UIButton *)button{
    
    self.selectedView = [[SelectedMonthView alloc]initWithFrame:CGRectMake((self.view.frame.size.width - 270)/2, self.view.frame.size.height/2-80, 270, 210)];
    [self.view addSubview:self.selectedView];
    
    self.selectedView.delegate = self;
    
    [self.selectedView selectedMonthView];
    
}
#pragma mark - 实现选择月份代理
- (void)didSelectMonth:(NSInteger)num{
    
    DLog(@"选择了 == %ld月",(long)num);
    
    self.selectedMonth = num;
    
    //   DLog(@"====%ld",self.selectedMonth);
    self.monthView.monthLabel.text = [NSString stringWithFormat:@"%ld月",self.selectedMonth+1];
    
    NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:[NSString stringWithFormat:@"%ld",self.selectedMonth] forKey:@"month"];
    [userDefaults synchronize];
    
    if (self.selectedMonth <= 9) {
        
        self.selectedTime = [NSString stringWithFormat:@"%@-0%ld",self.yearStr,self.selectedMonth+1];
    }else{
        
        self.selectedTime = [NSString stringWithFormat:@"%@-%ld",self.yearStr,self.selectedMonth+1];
    }
    
    
    [self postCheckReadingQueryData];
    
}


#pragma mark - 获取楼栋信息
- (void)postFloorQueryData
{
    NSDictionary * parms = @{
                             @"CommunityID":userModel.CommunityID,
                             @"json":@"\{\"jsonEntity\":\{},\"action\":\"getbuilding\",\"version\":\"V1.0\"}"};
    [HomeNetWorkRequest postFloorQuerySuccess:^(id data) {
        
        NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        
        NSString * str = [NSString stringWithFormat:@"%@",dict[@"Data"]];
        NSData * data2 = [str dataUsingEncoding:NSUTF8StringEncoding];
        NSArray * array = [NSJSONSerialization JSONObjectWithData:data2 options:NSJSONReadingMutableContainers error:nil];
        DLog(@"楼栋信息的数据 == %@",array);
        if (array.count != 0) {
            
            for (NSDictionary * dict in array) {
                
                HouseQueryModel * model = [[HouseQueryModel alloc]init];
                
                [model setValuesForKeysWithDictionary:dict];
                
                [self.floorArray addObject:model];
            }
            
            
        }
        
        [self.tableView reloadData];
        
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
        
        [self postCheckReadingQueryData];
        
    } Fail:^(NSString *errorDes) {
        
    } param:parms];
    
}
#pragma - mark - 抄表查询
- (void)postCheckReadingQueryData{
    
    NSDictionary * parms = nil;
    
    parms = @{
              @"Cid":userModel.CommunityID,
              @"BuildUnitId":self.BuildUnitId,
              @"RoomName":self.searchStr,
              @"Time":self.selectedTime,
              @"json":@"\{\"jsonEntity\":\{},\"action\":\"meterreadinglist\",\"version\":\"V1.0\"}"
              };
    
    DLog(@"=== 参数提交 === %@",parms);
    [HomeNetWorkRequest postCheckReadingQuerySuccess:^(id data) {
        
        [self.checkArray removeAllObjects];
        
        [self.readedArray removeAllObjects];
        
        NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        
        NSString * str = [NSString stringWithFormat:@"%@",dict[@"Data"]];
        NSData * data2 = [str dataUsingEncoding:NSUTF8StringEncoding];
        NSDictionary * dict1 = [NSJSONSerialization JSONObjectWithData:data2 options:NSJSONReadingMutableContainers error:nil];
        NSArray * array = dict1[@"notread"];
        NSArray * array1 = dict1[@"read"];
        
        DLog(@"抄表信息的数据 == %@",str);
        if (array.count != 0) {
            
            for (NSDictionary * dic in array) {
                
                CheckReadModel * model = [[CheckReadModel alloc]init];
                [model setValuesForKeysWithDictionary:dic];
                
                [self.checkArray addObject:model];
                
                DLog(@"抄表类型 == %@",model.MeterReadingType);
            }
            
        }
        if (array1.count != 0) {
            
            for (NSDictionary * dic1 in array1) {
                
                CheckReadModel * model = [[CheckReadModel alloc]init];
                [model setValuesForKeysWithDictionary:dic1];
                
                [self.readedArray addObject:model];
                
            }
        }
       
        
        DLog(@"返回未抄表个数 === %ld",self.checkArray.count);
        DLog(@"返回已抄表个数 === %ld",self.readedArray.count);
        
        [self.collectionView reloadData];
        
        if (self.checkArray.count == 0 && self.readedArray.count == 0) {
            
            self.placehoderImg.hidden = NO;
            self.titleLabel.hidden = NO;
        }else{
        
            self.placehoderImg.hidden = YES;
            self.titleLabel.hidden = YES;
        }
        
        
    } Fail:^(NSString *errorDes) {
        
        
    } param:parms];
    
}
#pragma mark - 获取系统时间
- (void)getYearAndMonthData{
    
    NSDate *date = [NSDate date];
    NSTimeZone *zone = [NSTimeZone systemTimeZone];
    NSTimeInterval time = [zone secondsFromGMTForDate:date];
    NSDate *dateNow = [date dateByAddingTimeInterval:time];
    NSString * timeDataStr = [NSString stringWithFormat:@"%@",dateNow];
    DLog(@" === %@",dateNow);
    
    NSArray * arr = [timeDataStr componentsSeparatedByString:@" "];
    DLog(@"日期格式化 == %@",arr[0]);
    
    NSArray * timeArr = [timeDataStr componentsSeparatedByString:@"-"];
    NSString * timeStr = [NSString stringWithFormat:@"%@-%@",timeArr[0],timeArr[1]];
    DLog(@"拼接好的时间===%@",timeStr);
    self.selectedTime = timeStr;
    self.yearStr = timeArr[0];
    
}
-(void)getCalendar{
    
    NSDate* nowTime = [NSDate date];
    
    NSCalendar * cal= [NSCalendar currentCalendar];
    
    unsigned int unitFlags= NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute|NSCalendarUnitSecond;
    
    NSDateComponents* dd = [cal components:unitFlags fromDate:nowTime];
    
    DLog(@"月份 = %ld",(long)dd.month);
    
    self.monthStr = [NSString stringWithFormat:@"%ld月",dd.month];
    
}
#pragma mark - 暂未图
- (void)createPlaceHolder
{
    
    self.placehoderImg = [[UIImageView alloc]init];
    [self.collectionView addSubview:self.placehoderImg];
    self.placehoderImg.image = [UIImage imageNamed:@"ico_meter_reading_empty"];
    
    [self.placehoderImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.collectionView).with.offset(0);
        make.top.equalTo(self.collectionView.mas_bottom).with.offset(100);
        make.size.mas_equalTo(CGSizeMake(80, 80));
    }];
    
    self.titleLabel = [[UILabel alloc]init];
    [self.collectionView addSubview:self.titleLabel];
    self.titleLabel.text = @"暂无抄表内容";
    
    self.titleLabel.textColor= BHColor(153, 153, 153);
    self.titleLabel.font = BHFont(15);
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.collectionView).with.offset(0);
        make.top.equalTo(self.placehoderImg.mas_bottom).with.offset(10);
        make.size.mas_equalTo(CGSizeMake(100, 25));
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
}


@end
